 grammar aufgabe1_grammar;
 
 options {
  output=AST; 
  ASTLabelType=CommonTree; 
 }
 
 tokens {RAETSEL;GLEICH;}
 
 /*------------------------------------------------------------------
  * PARSER RULES
  *------------------------------------------------------------------*/
 raetsel: ( a1=zblock o1=operator a2=zblock '=' a3=zblock
 	    o2=operator o3=operator o4=operator
 	    a4=zblock o5=operator a5=zblock '=' a6=zblock
 	    '=' '=' '='
 	    a7=zblock o6=operator a8=zblock '=' a9=zblock)
 	    -> ^(RAETSEL ^(GLEICH ^($o1 $a1 $a2) $a3) ^(GLEICH ^($o2 $a1 $a4) $a7) ^(GLEICH ^($o3 $a2 $a5) $a8) ^(GLEICH ^($o4 $a3 $a6) $a9) ^(GLEICH ^($o5 $a4 $a5) $a6) ^(GLEICH ^($o6 $a7 $a8) $a9));
  
zblock	: Z_BLOCK; 
 
operator 
: OPERATOR;
 
/*------------------------------------------------------------------
* LEXER RULES
*------------------------------------------------------------------*/
Z_BLOCK : ('A'..'H'|'J'|'K')+; // 'I' kommt in den Raetseln nicht vor.
OPERATOR : ('+'|'-');
EOF : ('\r' | '\n')+;
WHITESPACE : ('\t' | ' ')+ { $channel = HIDDEN; };